package effect.character.single;

import board.BoardUtil;
import character.MyCharacter;
import modifier.character.CharacterModifier;
import com.jme3.math.Vector3f;
import effect.Effect;
import game.CombatController;
import java.util.ArrayList;
import java.util.List;

public class SingleCharacterEffect extends Effect {
    protected MyCharacter target;
    protected List<CharacterModifier> characterModifiers = new ArrayList<CharacterModifier>();

    @Deprecated
    protected SingleCharacterEffect() {}
    
    public SingleCharacterEffect(MyCharacter owner) {
	super(owner);
    }
    
    public void applyEffect() {
        switch(effectType) {
            case DAMAGE:
                System.out.println(effectName+" hits "+target+" for "+baseEffectAmount+" points of damage.");
                CombatController.dealDamage(owner, target, Math.round(baseEffectAmount));
                break;
            case HEALING:
                System.out.println("Heal restores "+baseEffectAmount+" hit points to "+target+".");
                CombatController.heal(owner, target, Math.round(baseEffectAmount));
                break;
            case STATUS:
                target.addCharacterModifiers(characterModifiers);
                break;
        }
    }
    
    public void addCharacterModifier(CharacterModifier characterModifier) {
	characterModifiers.add(characterModifier);
    }
    
    public Vector3f getParticleEffectLocation() {
	return BoardUtil.getAverageWorldLocation(target.getOccupiedLocations());
    }

    public MyCharacter getTarget() {
	return target;
    }
    public void setTarget(MyCharacter target) {
	this.target = target;
    }
}
